import { get, post, put, del } from '@/utils/request'

// export function listAll() {
//     return request({
//         url: '/user/listAll',
//         method: 'get',
//         data: null,
//     })
// }

export const listAll = async () => {
    try {
        const response = await get<any>('/user/listAll');
        return response;
    } catch (error) {
    }
};

export const normalLogin = async (data: any) => {
    try {
        const response = await post<any>('/user/normalLogin', data);
        return response;
    } catch (error) {
    }
};

export const userLogout = async () => {
    try {
        const response = await post<any>('/user/logout');
        return response;
    } catch (error) {
    }
};

export const wxRender = async () => {
    try {
        const response = await get<any>('/user/wxRender');
        return response;
    } catch (error) {
    }
};

export const addUser = async (data: any) => {
    try {
        const response = await post<any>('/user/add', data);
        return response;
    } catch (error) {
    }
};

export const updateUser = async (data: any) => {
    try {
        const response = await post<any>('/user/update', data);
        return response;
    } catch (error) {
    }
};

export const deleteUser = async (data: any) => {
    try {
        const response = await post<any>('/user/delete', data);
        return response;
    } catch (error) {
    }
};

export const pageUser = async (data: any) => {
    try {
        const response = await post<any>('/user/page', data);
        return response;
    } catch (error) {
    }
};

export const getRoleByUserId = async (data: any) => {
    try {
        const response = await get<any>('/userRole/getRoleByUserId', data);
        return response;
    } catch (error) {
    }
};

export const userRoleSetting = async (data: any) => {
    try {
        const response = await post<any>('/userRole/userRoleSetting', data);
        return response;
    } catch (error) {
    }
};

export const currentUserInfo = async () => {
    try {
        const response = await post<any>('/user/currentUserInfo');
        return response;
    } catch (error) {
    }
};

export const changePassword = async (data: any) => {
    try {
        const response = await post<any>('/user/changePassword', data);
        return response;
    } catch (error) {
    }
};

export const namePhoneSetting = async (data: any) => {
    try {
        const response = await post<any>('/user/namePhoneSetting', data);
        return response;
    } catch (error) {
    }
};

export const currentUserMemberInfo = async () => {
    try {
        const response = await get<any>('/member/currentUserMemberInfo');
        return response;
    } catch (error) {
    }
};

export const currentUserMenu = async () => {
    try {
        const response = await get<any>('/user/currentUserMenu');
        return response;
    } catch (error) {
    }
};

export const intervalGetLoginStatus = async (data: any) => {
    try {
        const response = await get<any>('/user/intervalGetLoginStatus', data);
        return response;
    } catch (error) {
    }
};

export const offlineUser = async (data: any) => {
    try {
        const response = await post<any>('/user/offline', data);
        return response;
    } catch (error) {
    }
};

export interface User {
    id: number,
    name: string,
    phone: string,
    wxNickName: string,
    wxAvatar: string,
    tokenExpireTime: string,
    onlineStatus: boolean,
}
export interface ChangePasswordRequest {
    id: number | null,
    oldPassword: string,
    newPassword: string,
    repeatNewPassword: string,
}
export interface CurrentUserInfo {
    id: number,
    name: string,
    phone: string,
    wxAvatar: string,
}
export interface CurrentUserMemberInfo {
    member: boolean,
    memberPrice: string,
    expiryDateEnd: string,
}
export interface MemberInfoResponse {
    status: number,
    data: CurrentUserMemberInfo,
    msg: string,
}
export interface UserBaseInfoRequest {
    id: number | null,
    name: string,
    phone: string,
    password: string,
}
export interface QueryParams {
    pageNum: number,
    pageSize: number,
    name: string,
    phone: string,
}
export interface UserAddRequest {
    id: number | null,
    name: string,
    phone: string,
    password: string,
}
export interface CurrentUserRoleRequest {
    userId: number | null,
}
export interface LoginParams {
    phone: string,
    password: string,
}
export interface UserInfoResponse {
    token: string,
    menuList: Menu[],
}
export interface Menu {
    enName: string,
}
export interface AppIdRedirectUrl {
    wxClientId: string,
    redirectUrl: string,
    state: string,
}